﻿using Orchard.Events;
using Orchard.Security;
using Wolf.LoggedInUsers.Services;

namespace Wolf.LoggedInUsers.EventHandlers
{
    public interface IUserEventHandler : IEventHandler
    {
        void LoggedIn(IUser user);
        void LoggedOut(IUser user);
    }

    public class UserEventHandler : IUserEventHandler
    {
        private readonly ILoggedInUsersService _loggedInUsersService;

        public UserEventHandler(ILoggedInUsersService loggedInUsersService)
        {
            _loggedInUsersService = loggedInUsersService;
        }

        public void LoggedIn(IUser user)
        {
            _loggedInUsersService.UpdateUser(user);
        }

        public void LoggedOut(IUser user)
        {
            _loggedInUsersService.UserLoggedOut(user);
        }
    }
}